// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class PkItem extends cc.Component {
    @property(cc.Node)
    private pkNode: cc.Node = null;

    public initItem(pkName:string,index:number,pos:any){
        cc.loader.loadRes(`ui/pk/${pkName}${index}`,cc.SpriteFrame,(err,res)=>{
            if(err){
               console.log('error');
            }
            this.pkNode.name =`pk${index}`
            // this.pkNode.zIndex = Math.abs(13-index)
            this.pkNode.getComponent(cc.Sprite).spriteFrame = res
            this.pkNode.setPosition(pos)
        })
    }
}
